﻿using ArtMath.Attribute;
using ArtMath.Core.Helper;
using ArtMath.Data;
using ArtMath.Setting;
using System;
using System.ComponentModel;
using System.Drawing;

namespace ArtMath.Component.Annotation
{
    /// <summary>
    /// 荧光笔
    /// </summary>
    [Serializable]
    public class Highlighter : PenBase
    {
        public Highlighter(SketchPad pad, string name, Color color, bool addToList = true) : base(pad, name, color, ToolTypeName.ygb, addToList)
        {
            penColor.Color = Color.FromArgb(127, penColor.Color);
            PenWidth = new PadStringX(Pad);
            //penSize.ParametersValueChanged += (StringX sender, double oldValue) =>
            //{
            //    if (penSize.Value < 5)
            //    {
            //        penSize.SetExpression(oldValue);
            //    }
            //};
            PenWidth.SetExpression(Settings.Instance.HighlighterPenLen);
        }
        [DefaultValue(typeof(Color), "Yellow")]
        public override Color PenColor
        {
            get
            {
                return base.PenColor;
            }

            set
            {
                base.PenColor = value;
            }
        }
        [DefaultValue(typeof(PadStringX), "30"), MultilingualDisplayName(null, "PenPoint", "Width")]
        public override PadStringX PenWidth
        {
            get
            {
                return base.PenWidth;
            }

            set
            {
                base.PenWidth = value;
            }
        }
        protected override float MinWidth
        {
            get
            {
                return 5;
            }
        }
        public override object CopyAndPaste(SketchPad pad)
        {
            Highlighter hl = new Highlighter(pad, Utility.GetNextAvailableName(Name, pad.CheckObjectNameExist), PenColor, LayerItem != null);
            afterNewCopy(hl);
            return hl;
        }
    }
}
